package service;

import bean.Class;
import dao.ClassDao;
import factory.ClassDaoFactory;

import java.util.List;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 5:12 下午 2021/6/5
 */
public class ClassService {
    private ClassDao classDao;

    public ClassService() {
        this.classDao = ClassDaoFactory.getClassDao();
    }

    public boolean addClassService(Class e) {
        if (classDao.addClass(e) == 1) {
            return true;
        }
        return false;
    }

    public boolean deleteClassService(int classNo) {
        if (classDao.deleteClass(classNo) == 1) {
            return true;
        }
        return false;
    }

    public List<Class> getClass(int classNo) {
        return classDao.selectClass(classNo);
    }

    public boolean updateClass(Class e) {
        if (classDao.updateClass(e) == 1) {
            return true;
        }
        return false;
    }

    public List<Class> getAllClass(int page) {
        return classDao.selectAllClass(page);
    }

    public boolean isEmptyClass(int classNo) {
        if ("0".equals(classDao.selectUserUnionClass(classNo))) {
            return true;
        }
        return false;
    }
}
